package com.ruoyi.basedata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.WfzSbjs;
import com.ruoyi.basedata.service.IWfzSbjsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 社保基数Controller
 * 
 * @author xiefeng
 * @date 2022-12-19
 */
@RestController
@RequestMapping("/basedata/sbjs")
public class WfzSbjsController extends BaseController
{
    @Autowired
    private IWfzSbjsService wfzSbjsService;

    /**
     * 查询社保基数列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzSbjs wfzSbjs)
    {
        startPage();
        List<WfzSbjs> list = wfzSbjsService.selectWfzSbjsList(wfzSbjs);
        return getDataTable(list);
    }

    /**
     * 导出社保基数列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:export')")
    @Log(title = "社保基数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzSbjs wfzSbjs)
    {
        List<WfzSbjs> list = wfzSbjsService.selectWfzSbjsList(wfzSbjs);
        ExcelUtil<WfzSbjs> util = new ExcelUtil<WfzSbjs>(WfzSbjs.class);
        util.exportExcel(response, list, "社保基数数据");
    }

    /**
     * 获取社保基数详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzSbjsService.selectWfzSbjsByFid(fid));
    }

    /**
     * 新增社保基数
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:add')")
    @Log(title = "社保基数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzSbjs wfzSbjs)
    {
        wfzSbjs.setFcreator(getUsername());
        wfzSbjs.setFlastupdateuser(getUsername());
        return toAjax(wfzSbjsService.insertWfzSbjs(wfzSbjs));
    }

    /**
     * 修改社保基数
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:edit')")
    @Log(title = "社保基数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzSbjs wfzSbjs)
    {
        wfzSbjs.setFlastupdateuser(getUsername());
        return toAjax(wfzSbjsService.updateWfzSbjs(wfzSbjs));
    }

    /**
     * 删除社保基数
     */
    @PreAuthorize("@ss.hasPermi('basedata:sbjs:remove')")
    @Log(title = "社保基数", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzSbjsService.deleteWfzSbjsByFids(fids));
    }
}
